﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WMS.FC.Domain.PersistenceObject.Business;
using WMS.FC.Infrastructure.Common;

namespace WMS.FC.Infrastructure.POConfig.Business
{
    public class MaterialTechnologyRouteConfig : POBaseConfig<MaterialTechnologyRoutePO>
    {
        public override void InitializeData(EntityTypeBuilder<MaterialTechnologyRoutePO> builder)
        {
        }

        public override void MapColumn(EntityTypeBuilder<MaterialTechnologyRoutePO> builder, ref int index)
        {
            builder.HasComment("电池物料绑定工艺路径表");
            builder.Property(entity => entity.CellMaterialCode).ConfigColumn("CELL_MATERIAL_CODE", "电池物料编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TechnologyRouteCode).ConfigColumn("TECHNOLOGY_ROUTE_CODE", "工艺路径编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.IsMainRoute).ConfigColumn("IS_MAIN_ROUTE", "是否主工艺路径").HasColumnOrder(index++);
            builder.Property(entity => entity.WarehouseCode).ConfigColumn("WAREHOUSE_CODE", "仓库编码", 50, true).HasColumnOrder(index++);
        }

        public override void MapIndex(EntityTypeBuilder<MaterialTechnologyRoutePO> builder)
        {
            builder.HasIndex(entity => new { entity.CellMaterialCode, entity.WarehouseCode }).HasDatabaseName($"IDX_{TableName}_1");
        }
    }
}
